package components.scenes;

import java.util.List;

import com.uqbar.vainilla.GameScene;
import components.CollisionableComponent;
import components.ComponentsHashTable;
import components.ComponentsMatrix;

public abstract class  CollisionablesScene<CC extends CollisionableComponent<CollisionablesScene, CC>> extends GameScene {
	private ComponentsMatrix<CC> componentsTable;

	public CollisionablesScene(){
		this.componentsTable = new ComponentsMatrix<CC>();
	}
	public CollisionablesScene(int matrixWidth, int matrixHeight, double deltaPossX, double deltaPossY){
		this.componentsTable = new ComponentsMatrix<CC>(matrixWidth, matrixHeight, deltaPossX, deltaPossY);
	}
	
	public void setComponentsTable(ComponentsMatrix<CC> componentsTable) {
		this.componentsTable = componentsTable;
	}

	public ComponentsMatrix<CC> getComponentsTable() {
		return componentsTable;
	}
	
	public void addCollisionable(CC gc){
		this.addComponent(gc);
		this.getComponentsTable().addCollisionableComponent(gc, gc.getX(), gc.getY());
	}
	public void addCollisionables(List<CC> ccs){
		for (CC cc : ccs){
			this.addCollisionable(cc);
		}
	}
	
	public void removeCollisionable(CC gc){
		this.getComponentsTable().remove(gc, gc.getX(), gc.getY());
		gc.destroy();
		this.removeComponent(gc);

	}
	public void removeFromMatrix(CC gc){
		this.getComponents().remove(gc);
		this.getComponentsTable().remove(gc, gc.getX(), gc.getY());
	}

}
